home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.UserControl FlappingFlag
- AutoRedraw = -1 'True
- ClientHeight = 1995
- ClientLeft = 0
- ClientTop = 0
- ClientWidth = 2325
- ScaleHeight = 133
- ScaleMode = 3 'Pixel
- ScaleWidth = 155
- ToolboxBitmap = "FlapFlag.ctx":0000
- Begin VB.Timer FlapTimer
- Enabled = 0 'False
- Interval = 100
- Left = 360
- Top = 1440
- End
- Begin VB.PictureBox FlapPict
- AutoRedraw = -1 'True
- AutoSize = -1 'True
- BorderStyle = 0 'None
- Height = 615
- Index = 0
- Left = 1080
- ScaleHeight = 41
- ScaleMode = 3 'Pixel
- ScaleWidth = 41
- TabIndex = 1
- Top = 240
- Visible = 0 'False
- Width = 615
- End
- Begin VB.PictureBox OrigPict
- AutoRedraw = -1 'True
- AutoSize = -1 'True
- BorderStyle = 0 'None
- Height = 615
- Left = 240
- ScaleHeight = 41
- ScaleMode = 3 'Pixel
- ScaleWidth = 41
- TabIndex = 0
- Top = 240
- Visible = 0 'False
- Width = 615
- End
- Attribute VB_Name = "FlappingFlag"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = True
- Attribute VB_Description = "CCC Flapping flag control"
- Option Explicit
- 'Event Declarations:
- Event DblClick()
- Attribute DblClick.VB_Description = "Occurs when the user double clicks on the flag."
- Event Click()
- Attribute Click.VB_Description = "Occurs when the user clicks on the flag."
- Const MaxFlaps = 5
- 'Default Property Values:
- Const m_def_Magnitude = 2
- 'Property Variables:
- Dim m_Magnitude As Single
- Dim FlagWid As Single
- Dim FlagHgt As Single
- Dim Showing As Integer
- ' *********************************************
- ' Show the About dialog.
- ' *********************************************
- Public Sub ShowAbout()
- Attribute ShowAbout.VB_Description = "Displays the About dialog."
- Attribute ShowAbout.VB_UserMemId = -552
- Dim frm As New AboutDialog
- frm.Show vbModal
- Set frm = Nothing
- End Sub
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MappingInfo=UserControl,UserControl,-1,BackColor
- Public Property Get BackColor() As OLE_COLOR
- Attribute BackColor.VB_Description = "Returns/sets the background color used to display text and graphics in an object."
- BackColor = UserControl.BackColor
- End Property
- Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR)
- UserControl.BackColor() = New_BackColor
- PropertyChanged "BackColor"
- End Property
- ' *********************************************
- ' Create the flapping pictures.
- ' *********************************************
- Private Sub MakePictures()
- Const PI = 3.14159265
- Dim i As Integer
- Dim offset As Single
- Dim Doffset As Single
- Dim Yoffset As Single
- Dim Yoffset1 As Single
- Dim X As Single
- Dim dx As Single
- FlagWid = OrigPict.Width
- FlagHgt = OrigPict.Height + 4 * (m_Magnitude)
- UserControl_Resize
- ' Make all the pictures the same.
- For i = 0 To MaxFlaps
- Set FlapPict(i).Picture = OrigPict.Picture
- FlapPict(i).Height = FlagHgt
- FlapPict(i).Line (0, 0)-(FlagWid, FlagHgt), _
- UserControl.BackColor, BF
- Next i
- offset = 0
- Doffset = 2 * PI / (MaxFlaps + 1)
- dx = FlagWid / (2.5 * PI)
- For i = 0 To MaxFlaps
- Yoffset1 = m_Magnitude * Sin(offset)
- For X = 0 To FlagWid - 1
- Yoffset = m_Magnitude * _
- (2 + Sin(offset + X / dx))
- FlapPict(i).PaintPicture _
- OrigPict.Picture, _
- X, Yoffset - Yoffset1, _
- 1, FlagHgt, X, 0, 1, FlagHgt
- Next X
- FlapPict(i).Picture = FlapPict(i).Image
- offset = offset + Doffset
- Next i
- Set UserControl.Picture = FlapPict(0).Picture
- End Sub
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MappingInfo=OrigPict,OrigPict,-1,Picture
- Public Property Get Picture() As Picture
- Attribute Picture.VB_Description = "Returns/sets a graphic to be displayed in a control."
- Set Picture = OrigPict.Picture
- End Property
- Public Property Set Picture(ByVal New_Picture As Picture)
- Set OrigPict.Picture = New_Picture
- ' Make the flapping pictures.
- MakePictures
- PropertyChanged "Picture"
- End Property
- Private Sub FlapTimer_Timer()
- Showing = (Showing + 1) Mod (MaxFlaps + 1)
- Set UserControl.Picture = _
- FlapPict(Showing).Picture
- End Sub
- Private Sub UserControl_Click()
- RaiseEvent Click
- End Sub
- Private Sub UserControl_DblClick()
- RaiseEvent DblClick
- End Sub
- Private Sub UserControl_InitProperties()
- Dim i As Integer
- For i = 1 To MaxFlaps
- Load FlapPict(i)
- Next i
- m_Magnitude = m_def_Magnitude
- FlagWid = 60
- FlagHgt = 100
- End Sub
- 'Load property values from storage
- Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
- Dim i As Integer
- UserControl.BackColor = PropBag.ReadProperty("BackColor", &H8000000F)
- Set OrigPict.Picture = PropBag.ReadProperty("OriginalPicture", Nothing)
- Set UserControl.Picture = PropBag.ReadProperty("Picture", Nothing)
- For i = 1 To MaxFlaps
- Load FlapPict(i)
- Next i
- For i = 0 To MaxFlaps
- Set FlapPict(i).Picture = PropBag.ReadProperty("FlapPicture" & Format$(i), Nothing)
- Next i
- UserControl.Enabled = PropBag.ReadProperty("Enabled", False)
- If Ambient.UserMode Then _
- FlapTimer.Enabled = UserControl.Enabled
- m_Magnitude = PropBag.ReadProperty("Magnitude", m_def_Magnitude)
- FlagWid = FlapPict(0).Width
- FlagHgt = FlapPict(0).Height
- Randomize
- Showing = Int((MaxFlaps + 1) * Rnd)
- End Sub
- Private Sub UserControl_Resize()
- Static resizing As Boolean
- ' Do not recurse.
- If resizing Then Exit Sub
- resizing = True
- Size ScaleX(FlagWid, vbPixels, vbTwips), _
- ScaleY(FlagHgt, vbPixels, vbTwips)
- resizing = False
- End Sub
- 'Write property values to storage
- Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
- Dim i As Integer
- Call PropBag.WriteProperty("BackColor", UserControl.BackColor, &H8000000F)
- Call PropBag.WriteProperty("OriginalPicture", OrigPict.Picture, Nothing)
- Call PropBag.WriteProperty("Picture", UserControl.Picture, Nothing)
- Call PropBag.WriteProperty("Enabled", UserControl.Enabled, False)
- For i = 0 To MaxFlaps
- Call PropBag.WriteProperty("FlapPicture" & Format$(i), FlapPict(i).Picture, Nothing)
- Next i
- Call PropBag.WriteProperty("Magnitude", m_Magnitude, m_def_Magnitude)
- End Sub
- Public Property Get FlappedImage() As Picture
- Attribute FlappedImage.VB_Description = "The flapped picture."
- Attribute FlappedImage.VB_MemberFlags = "400"
- Set FlappedImage = UserControl.Picture
- End Property
- Public Property Set FlappedImage(ByVal New_FlappedImage As Picture)
- If Ambient.UserMode = False Then Err.Raise 383
- If Ambient.UserMode Then Err.Raise 382
- Set UserControl.Picture = New_FlappedImage
- PropertyChanged "FlappedImage"
- End Property
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MappingInfo=UserControl,UserControl,-1,Enabled
- Public Property Get Enabled() As Boolean
- Attribute Enabled.VB_Description = "Returns/sets a value that determines whether an object can respond to user-generated events."
- Enabled = UserControl.Enabled
- End Property
- Public Property Let Enabled(ByVal New_Enabled As Boolean)
- UserControl.Enabled() = New_Enabled
- If Ambient.UserMode Then _
- FlapTimer.Enabled = New_Enabled
- PropertyChanged "Enabled"
- End Property
- Public Property Get Magnitude() As Single
- Attribute Magnitude.VB_Description = "The amount by which the flag is displaced vertically."
- Magnitude = m_Magnitude
- End Property
- Public Property Let Magnitude(ByVal New_Magnitude As Single)
- m_Magnitude = New_Magnitude
- PropertyChanged "Magnitude"
- End Property
-